package com.wontube.smr.remote.web;

import com.wontube.client.modle.vo.PagenateInfo;
import com.wontube.core.annotation.CacheSupport;
import com.wontube.core.annotation.NoLoginSupport;
import com.wontube.core.pub.servlet.handlers.BasicHandler;
import com.wontube.smr.bo.constants.SiteConstants;
import com.wontube.smr.bo.sites.VideoSelectBO;
import com.wontube.smr.bo.sites.youtube.feed.YouTubeFeedsBO;
import com.wontube.smr.client.model.po.Movie;
import com.wontube.smr.client.model.vo.MovieItems;
import com.wontube.smr.client.model.vo.SearchCountPreview;
import com.wontube.smr.client.model.vo.TVShowItems;
import com.wontube.smr.client.model.vo.VVideoItems;
import com.wontube.smr.dao.bo.MovieSelectDao;
import com.wontube.smr.dao.bo.TVSelectDao;
import com.wontube.smr.web.client.IVideoSearchWebHandler;

/**
 * @author tanggf(2012-8-11)
 *
 */
@NoLoginSupport
public class VideoSearchWebHandler extends BasicHandler implements IVideoSearchWebHandler{
	@Override
	@CacheSupport
	public SearchCountPreview getSearchCountPreview(String query) {
		return VideoSelectBO.previewItemsCount(query);
	}

	@Override
	@CacheSupport
	public VVideoItems searchAllVideos(double dbFactor, String query,
			PagenateInfo pageInfo) {
		return VideoSelectBO.searchAllVideosForWeb(dbFactor, query, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchMovies(String query,	PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_MOVIE, SiteConstants.WEBSITE_HULU, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchTrailers(String query, PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_TRAILER, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchMusics(String query, PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_MUSIC, SiteConstants.WEBSITE_VEVO, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchYoutubeShortFilms(String query, PagenateInfo pageInfo) {
		return YouTubeFeedsBO.searchVideoFeeds(query, null, pageInfo);		
	}

	@Override
	@CacheSupport
	public TVShowItems searchHuluTVShows(String query, PagenateInfo pageInfo) {
		return TVSelectDao.searchHuluTVShows(query, pageInfo);
	}

	//==========i18n=========
	@Override
	@CacheSupport
	public SearchCountPreview getI18nSearchCountPreview(String query) {
		return VideoSelectBO.previewI18nItemsCount(query);
	}

	@Override
	@CacheSupport
	public VVideoItems searchAllVideosForI18n(double dbFactor, String query,
			PagenateInfo pageInfo) {
		return VideoSelectBO.searchAllVideosForI18n(dbFactor, query, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchMoviesForI18n(String query, PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_MOVIE, SiteConstants.WEBSITE_YOUTUBE, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchTrailersForI18n(String query, PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_TRAILER, SiteConstants.WEBSITE_IMDB, pageInfo);
	}

	@Override
	@CacheSupport
	public TVShowItems seachAnimesForI18n(String query, PagenateInfo pageInfo) {
		return TVSelectDao.searchCrunchyrollAnimes(query, pageInfo);
	}

	@Override
	@CacheSupport
	public MovieItems searchMusicsForI18n(String query, PagenateInfo pageInfo) {
		return MovieSelectDao.search(query, Movie.TYPE_MUSIC, SiteConstants.WEBSITE_YOUTUBE, pageInfo);
	}
}
